<?php include view('header');?>

<h1>项目列表</h1>

<form action="project.php?action=quicksearch" method="post">
    <label>快速搜索：</label>
    <?php echo Tpl::select('searchmode', array('按项目代码搜索','按项目名称搜索'));?>
    <input type="text" id="quicksearch" name="quicksearch" />
    <button type="submit">搜索</button>
</form>
<div class="list">
<table>
	<thead>
    	<tr><td>项目代码</td><td>项目名称</td><td>到账时间</td><td>总捐赠金额</td><td width="60">操作</td></tr>
    </thead>
    <tbody>
    	<?php if(is_array($projectlist)) foreach($projectlist as $p){
			$progress = round($p['restamount'] / $p['amount'] * 100);
			if($progress <= 10){
				$background = 'red';//红色警示
			}else if($progress <= 50){
				$background = 'yellow';//黄色警示
			}else{
				$background = 'green';
			}
			?>
            <tr>
			<td><a href="project.php?action=more&id=<?php echo $p['id'];?>"><?php echo empty($p['code']) ? '无' : $p['code'];?></a></td>
            <td><a href="project.php?action=more&id=<?php echo $p['id'];?>"><?php echo empty($p['name']) ? '无' : $p['name'];?><br /><span class="source">捐赠单位：<?php echo $p['source'];?></span></a><div class="progressbar"><div class="<?php echo $background;?>" style="width:<?php echo $progress;?>%;"><?php echo $progress;?>%</div></div></td>
            <td><a href="project.php?action=more&id=<?php echo $p['id'];?>"><?php if(empty($p['creditedtime']))echo '无';else echo rgmdate($p['creditedtime'], 'Y-m-d');?></a></td>
			<td><?php echo $p['amount']?>元</td>
            <td><a href="project.php?action=more&id=<?php echo $p['id'];?>">[查看]</a><br />
            <a href="project.php?action=edit&id=<?php echo $p['id'];?>">[修改]</a><br />
            <a href="project.php?action=delete&name=<?php echo $p['name'];?>&id=<?php echo $p['id'];?>">[删除]</a></br>
            <a href="project.php?action=editprocess&id=<?php echo $p['id'];?>">[添加进程]</a></td>
			</tr>
			<?php }?>
    </tbody>
</table>
</div>
<?php echo Tpl::mpage($pageNum, $page, $limit, 'project.php?action='.$_GET['action']);?>

<?php include view('footer');?>
